﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
	<title>The Free Market | Mukti '10</title>	
	<link rel="shortcut icon" href="images/favicon.ico" />
	<%= stylesheet_link_tag 'style' %>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<meta http-equiv="content-language" content="en-gb" />
	<meta http-equiv="imagetoolbar" content="false" />
	<meta name="author" content="Shreyank Gupta"/>
	<meta name="copyright" content="Copyright (c) Linux Users' Group, NIT Durgapur 2009" />
	<meta name="description" content="" />
	<meta name="keywords" content="" />	
	<meta name="last-modified" content="Sat, 01 Dec 2008 00:00:00 GMT" />
	<meta name="mssmarttagspreventparsing" content="true" />	
	<meta name="robots" content="index, follow, noarchive" />
	<meta name="revisit-after" content="7 days" />
</head>

<body>
	<div id="header">
		<h1>The Free Market</h1>
		<p>Share with Shares...</p>
		<ul>
			<li><%= link_to 'Portfolio',  :controller => "welcome"  %></li>
			<li><%= link_to 'Market',  :controller => "market"  %></li>
			<li><%= link_to 'Triggers',  :controller => "triggers"  %></li>
			<li><%= link_to 'Rankings',  :controller => "ranks"  %></li>
			<li><%= link_to 'Read Me',  :controller => "help"  %></li>
		</ul>	
	</div>
	<div id="content">
	  <div id="ticker"><marquee><i>Today's Freemex</i> 
	  <% stocks = Stock.now %>
	  <% for stock in stocks %>
	   | 
	  <b><%= h stock.name %></b>
      <%= h stock.market_value %>
      <% if !stock.days_opening.nil? %>
      <% trend = stock.market_value - stock.days_opening %>
      <% else
      		trend = 0
      	end %>
    	<% if trend == 0 %>
    <img src="/images/side.png" height=6px width=6px />
    <% elsif trend < 0 %>
    <img src="/images/down.png" height=6px width=6px />
    <%= -trend %>
    <% else %>
    <img src="/images/up.png" height=6px width=6px />
    <%= trend %>
    <% end %>
    <% end %>
	  </marquee></div>
  	  <div id="ticker"><marquee><%= Ticker.now %></marquee></div>
		<div id="sidebar">
			<h1>Welcome, <% if logged_in? %><%= current_user.login.capitalize %><% else %> Guest <% end %></h1>
			<p>
			<% if !Flag.first.nil? %>
			<b>Its Day <%= Flag.day %>, <%= Date.today.to_formatted_s(:long) %></b><br />
			<b>Freemex : <%= number_with_precision(Stock.freemex?, 2) %>
			<% freemex_trend = Stock.freemex? - Stock.open_freemex? %>
    	<% if freemex_trend == 0 %>
    <img src="/images/side.png" height=10px width=10px />
    <% elsif freemex_trend < 0 %>
    <img src="/images/down.png" height=10px width=10px />
    <%= number_with_precision(-freemex_trend, 2) %>
    <% else %>
    <img src="/images/up.png" height=10px width=10px />
    <%= number_with_precision(freemex_trend, 2) %>
    <% end %></b>
			<br/>
			<% if Flag.open? == 1 %>
			The Free Market is open till 10pm!
			<% else %>
			The Free Market is closed now!
			<% end %> 
			<% end %>
			<%= link_to_if logged_in?, 'Logout>>', session_path, :method => :delete, :class => "more" do
    					end %>
			</p>
			<% if logged_in? %>
			<h1>Your Updates</h1>
			<p>
			<% updates = Update.now(current_user) %>
			<% for update in updates %>
			<% name, dummy = Ownership.details(update.stock_id) %>
			You <%= update.what %> <%= update.quantity %> stocks of <%= name %> at <%= update.price %><br />
			<% end %>
			<%= link_to 'View All...',  :controller => "updates" %>
			<% end %>
			</p>
			<% if admin? %>
			<h1>Admin Panel</h1>
			<p><%= link_to 'Click Here', :controller => 'admin' %></p> 
			<% end %>
			<h1>Links</h1>
			<ul>
				<li><a href="http://mkti.in">Mukti '10</a></li>
				<li><a href="http://lug.nitdgp.ac.in">GNU/Linux Users' Group, NIT Durgapur</a></li>
				<li><a href="http://nitdgp.ac.in">NIT, Durgapur</a></li>

			</ul>
			
		</div>
		<div id="main">
			<% if flash[:notice] %><div id="notice" class="notice"><%= flash[:notice] %></div><% end %>
			<%= yield  %>
		</div>
	</div>
	<div id="footer">
		<p>Copyright &copy; <a href="http://lug.nitdgp.ac.in">GNU/Linux Users' Group, NIT Durgapur</a> 2010 | Developed by <a href="http://allsortsofshrink.blogspot.com/">Shreyank Gupta</a> | Template by <a href="http://www.edg3.co.uk/">edg3.co.uk</a></p>
	</div>
</body>

</html>
